package com.recipedb.recipedb.controller;

import com.recipedb.recipedb.entity.RecipeDifficultyVote;
import com.recipedb.recipedb.entity.RecipeDifficultyVoteId;
import com.recipedb.recipedb.service.RecipeDifficultyVoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;

@RestController
@RequestMapping("/api/recipedifficultyvote")
public class RecipeDifficultyVoteController {

    @Autowired
    private RecipeDifficultyVoteService service;

    @PostMapping
    public RecipeDifficultyVote add(@RequestBody RecipeDifficultyVote entity) {
        return service.save(entity);
    }

    @DeleteMapping
    public void delete(@RequestBody RecipeDifficultyVoteId id) {
        service.deleteById(id);
    }

    @GetMapping("/single")
    public Optional<RecipeDifficultyVote> get(@RequestBody RecipeDifficultyVoteId id) {
        return service.findById(id);
    }

    @GetMapping("/all")
    public List<RecipeDifficultyVote> getAll() {
        return service.findAll();
    }
}
